<%@page import="edu.sdibt.bean.Student1"%>
<%@page import="edu.sdibt.bean.Student"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.student{
   border-spacing:0;
     border-collapse: collapse; 
}
.student th,.student td{
   border: 1px black solid;
}
</style>
<script type="text/javascript">
window.onload=function(){
	var dels=document.getElementsByClassName("del");
	for(var i=0;i<dels.length;i++){
		dels[i].onclick=function(){
			var name=this.parentNode.parentNode.getElementsByTagName("td")[1].innerText;
			var flag=confirm("确定要删除"+name+"的记录吗");
			return flag;
		};
	}
};

</script>
</head>
<body>
      <form action="select.do">
      <table>
          <tr>
              <td>ID:</td> 
              <td><input type="text" name="id"/></td>      
          </tr>
          <tr>
              <td>Name:</td> 
              <td><input type="text" name="name"/></td>      
          </tr>
          <tr>
              <td>Password:</td> 
              <td><input type="text" name="password"/></td>      
          </tr>
          <tr>
              <td><input type="submit" value="Query"/></td>  
              <td><a href="addstudent.jsp">Add New Student</a></td>    
          </tr>
      </table>
      </form>
      <%List<Student> list=(List<Student>)request.getAttribute("s"); 
      if(list!=null&&list.size()>0){
      %>
      <br>
      <hr>
      <br>
      <table class="student">
          <tr>
              <th>ID</th>
              <th>Name</th>
              <th>Password</th>
              <th>Update</th>
              <th>Delete</th>
          </tr>
          <%
          for(Student student:list){
          %>
          <tr>
              <td><%=student.getId()%></td>
              <td><%=student.getName()%></td>
              <td><%=student.getPassword()%></td>
              <td><a href="edit.do?id=<%=student.getId() %>">Update</a></td>
              <td><a href="delete.do?id=<%=student.getId()%>" class="del">Delete</a></td>
          </tr>
          <%
          }
          %>
          
      </table>
      <%
      }
      %>
</body>
</html>